package com.yourcurtain.client;

import java.util.HashMap;

import com.google.gwt.user.client.History;

public abstract class HistoryManager {

	public static String SYMBOL_START = "?";
	public static String SYMBOL_SEPARATOR = "&";
	public static String SYMBOL_ASSIGNMENT = "=";
	public static String TITLE = "title";
	
	//Title name
	public static String ANIME="anime";
	public static String MUSIC="music";
	public static String MOVIE="movie";
	public static String INDEX="index";
	

	private static HashMap<String, String> parameters = new HashMap<String, String>();

	public static void addHistoryToken() {
		String token = getToken();
		History.newItem(token, true);
	}

	private static String getToken() {

		StringBuffer token = new StringBuffer(SYMBOL_START);

		int counter = 0;
		for (String state : parameters.keySet()) {
			counter++;
			String value = parameters.get(state);
			token.append(state + SYMBOL_ASSIGNMENT + value);
			if (counter != parameters.size()) {
				token.append(SYMBOL_SEPARATOR);
			}
		}
		return token.toString();
	}

	public static void putTitle(String value) {
		parameters.put(TITLE, value);
	}
	
	public static void clearParameter() {
		parameters.clear();
	}
	
	

	

}
